import * as TYPE from './mutation-type';
function setPage(state,option){
    if(!option){
        state.pager={ pagerNumer:1, pageSize:5, recordCount:0};
        return;
    }
    if(option.pagerNumer) state.pager.pagerNumer = option.pagerNumer;
    if(option.pageSize) state.pager.pageSize = option.pageSize;
    if(option.recordCount) state.pager.recordCount = option.recordCount;
}
export default {
    /* 加法 */
    [TYPE.COUNTER_ADD](state){
        state.count++;
    },
    /* 减法 */
    [TYPE.COUNTER_DEC](state){
        state.count--;
    },
    //分页状态
    [TYPE.SET_PAGER](state,option){
        setPage(state,option);
        // if(!option){
        //     state.pager={ pagerNumer:1, pageSize:5, recordCount:0};
        //     return;
        // }
        // if(option.pagerNumer) state.pager.pagerNumer = option.pagerNumer;
        // if(option.pageSize) state.pager.pageSize = option.pageSize;
        // if(option.recordCount) state.pager.recordCount = option.recordCount;
    },
    //列表
    [TYPE.RECEIVE_CONTACT_LIST](state,ret){
        state.contactList = ret.list;
        setPage(state,ret.pager);
    },
    //联系人详情
    [TYPE.RECEIVE_CONTACT_DETAIL](state,detail){
        state.contactDetail = detail;
    },
    
}
